//
//  TestViewController.m
//  ios11-1
//
//  Created by mac on 15-11-6.
//  Copyright (c) 2015年 Lee. All rights reserved.
//

#import "TestViewController.h"
#import "ViewController.h"
@interface TestViewController ()//类的扩展，可以不被看到
{
    NSArray * data;
    NSArray * detail;
}
@end

@implementation TestViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return data.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];
    cell.textLabel.text = data[indexPath.row];
    cell.detailTextLabel.text = detail[indexPath.row];
    
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
    return cell;
}


- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    data = @[
                @"saojdhnasiudi",
                @"dddddddd",
                @"阿妈赛事放房间爱搜"
                ];
    detail = @[
               @"1",
               @"2",
               @"3"
               ];
    self.navigationItem.rightBarButtonItem = self.editButtonItem;
    self.title = @"第二个控制器";
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    ViewController * con = [ViewController new];
    [self.navigationController pushViewController:con animated:YES];
}

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath{
    return YES;
}

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath{
    
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
    if (editingStyle  == UITableViewCellEditingStyleDelete) {
        NSMutableArray * arr = data.mutableCopy;
        [arr removeObjectAtIndex:indexPath.row];
        data = arr;
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
